function postDialog()
{
	$(':submit').attr('disabled',true);
	
	if($('#autoFrame').length == 0)
	{
		$('body').append('<iframe class="hidden" id="autoFrame" name="autoFrame" ></iframe>');
	}	
	
	if($('.ui-dialog').length > 0)
	{
		$('.ui-dialog').remove();
	}
	
	$('<div class="ui-dialog-message"><span class="ui-dialog-loading">&nbsp;</span>正在处理,请稍候...</div>').dialog({
		close: function(){$(".ui-dialog").remove();$(".ui-dialog-message").remove();$(':submit').attr('disabled',false);},
		title: '提示信息',
		resizable : false
	});
}

function postResponse(response)
{
	$(".ui-dialog-message").html(response.message);
	
	if (response.javascript)
	{
		eval(response.javascript);
	}
	
	if (response.goUrl)
	{
		redirect(response.goUrl, response.stayTime)
	}
	else if (response.stayTime > 0)
	{
		window.setTimeout(function(){$(':submit').attr('disabled',false);$(".ui-dialog").hide('slow',function(){$(".ui-dialog").remove();$(".ui-dialog-message").remove();});},response.stayTime * 1000);
	}
	
}

function getDialog(url, goUrl, stayTime)
{
	if(stayTime == undefined) { stayTime = 3; }
	
	if($('.ui-dialog').length > 0)
	{
		$('.ui-dialog').remove();
	}
	
	$('<div class="ui-dialog-message"><span class="ui-dialog-loading">&nbsp;</span>正在处理,请稍候...</div>').dialog({
		title:'提示信息',
		resizable : false
	});
	
	$.ajax({
		type : 'get',
		dataType : 'json',
		url : url,
		success : function(response) 
		{
			$(".ui-dialog-message").html(response.message);
			
			if (response.javascript)
			{
				eval(response.javascript);
			}
			
			if (response.success && goUrl)
			{
				redirect(goUrl, stayTime);
			}
			else if (stayTime > 0)
			{
				window.setTimeout(function(){$(".ui-dialog").hide('slow');},stayTime*1000);
			}
		}
	});
}

function selAll(name)
{
	$("input[name='"+name+"']").attr("checked", true);
	
	return false;
}

function selNone(name)
{
	$("input[name='"+name+"']").attr("checked", false);
	
	return false;
}

function selAnti(name)
{
	$("input[name='"+name+"']").each(function(i){
		this.checked=!this.checked;
	});
	
	return false;
}

function getSel(name)
{
	var ids = '';
	$("input:checked[name='"+name+"']").each(function(i){
		ids+=this.value+',';
	});
	return ids.substr(0, ids.length - 1);
}

function redirect(goUrl, time)
{
	if(time == undefined) { time = 2; }
	window.setTimeout(function(){window.location.href=goUrl;},time*1000);
}

$(document).ready(function(){
	$(".content table tr,.rowLine")
	.mouseover(function(){
		if($(this).find("input[name='sel[]']").length > 0 && $(this).parents().find("input[name='sel[]']").length > 2)
		{
			$(this).removeClass("selected");
			$(this).addClass("titleBg");
		}
	})
	.mouseout(function(){
		if($(this).find("input[name='sel[]']").length > 0 && $(this).parents().find("input[name='sel[]']").length > 2)
		{
			if($(this).find("input[name='sel[]']").get(0).checked)
			{
				$(this).addClass("selected");
			}
			else
			{
				$(this).removeClass("selected");
			}
			$(this).removeClass("titleBg");
		}
	})
});